package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Setmeal;
import com.itheima.reggie.entity.dto.SetmealDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealMapper {

    @Select("select count(*) from setmeal where category_id=#{id}")
    int findCountByCategoryId(Long id);

    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void save(SetmealDto setmealDto);

    //根据ID删除套餐
    List<Setmeal> findByName(String name);

    //根据删除的id查询状态为1的套餐的总数量
    long findSetmealByStatus(@Param("ids") List<Long> ids);

    //根据ID删除套餐
    void deleteByIds(List<Long> ids);

    void updateStatusById(@Param("ids") List<Long> ids,@Param("status") Integer status);
}
